/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

            
var req;
var acceptButton;
var denyButton;

function denyRequest(form) {
    var url = "DenyRequest?requestId=" + escape(form.requestId.value);
    acceptButton = form.accept;
    denyButton = form.deny;
    
    req = initRequest();
    req.open("GET", url, true);
    req.onreadystatechange = denyRequest_callback;
    req.send(null);
}

function denyRequest_callback() {
    if (req.readyState == 4 && req.status == 200) {
        denyRequest_parseMessage(req.responseXML);
    }
}

function denyRequest_parseMessage(responseXML) {
    if (responseXML == null) {
        //
    } else {
      var message = responseXML.getElementsByTagName("message")[0];
      var toPrint = message.childNodes[0].nodeValue.toString();
      if (toPrint == "success") {
          // change here
          acceptButton.value = "Denied";
          acceptButton.disabled = true;
          
          // delete deny button
          denyButton.style.display = "none";
          
          //update numberOfRequests in side bar
          var numOfRequests = parseInt($("numOfRequests").innerHTML);
          $("numOfRequests").innerHTML = numOfRequests - 1;
      } else {
          alert(toPrint);
      }
    }
}
